package com.eco.fanliapp.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.eco.fanliapp.entity.AppUser;
import com.eco.fanliapp.entity.LoginSwitch;
import com.eco.fanliapp.vo.ChannelUserAffiliationVo;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

/**
 * APP用户 数据层
 *
 * @author xiaoxx
 * @date 2019-04-24
 */
public interface AppUserMapper extends BaseMapper<AppUser> {
    /**
     * 查询APP用户信息
     *
     * @param tableId APP用户ID
     * @return APP用户信息
     */
    AppUser selectAppUserById(Long tableId);

    /**
     * 查询APP用户列表
     *
     * @param appUser APP用户信息
     * @return APP用户集合
     */
    List<AppUser> selectAppUserList(AppUser appUser);

    /**
     * 新增APP用户
     *
     * @param appUser APP用户信息
     * @return 结果
     */
    int insertAppUser(AppUser appUser);

    /**
     * 修改APP用户
     *
     * @param appUser APP用户信息
     * @return 结果
     */
    int updateAppUser(AppUser appUser);

    /**
     * 删除APP用户
     *
     * @param tableId APP用户ID
     * @return 结果
     */
    int deleteAppUserById(Long tableId);

    /**
     * 批量删除APP用户
     *
     * @param tableIds 需要删除的数据ID
     * @return 结果
     */
    int deleteAppUserByIds(String[] tableIds);

    AppUser selectAppUserByPhoneNumber(String phoneNumber);

    AppUser selectAppUserByAlipayPhoneNumber(String phoneNumber);

    /**
     * 根据微信ID查询用户
     *
     * @param wechatUnionid
     * @return
     */
    AppUser selectAppUserByWechatUnionid(String wechatUnionid);

    List<AppUser> selectAppUserListByUserName(@Param("userName") String userName, @Param("companyId") Integer companyId);

    /**
     * 根据上级id查询粉丝
     *
     * @param meInviteCode
     * @return
     */
    List<AppUser> selectFansBySuperInviteCode(String meInviteCode);


    /**
     * 根据淘宝用户id查询用户
     *
     * @param taobaoUserId
     * @return
     */
    AppUser selectAppUserListByTaoBaoUserId(Long taobaoUserId);

    /**
     * 根据微信ID下载用户信息
     *
     * @param wechatUnionid
     * @return
     */
    AppUser downloadUserInformationByWechatUnionid(String wechatUnionid);

    /**
     * @param userId
     * @param userRealName
     * @param alipayAccount
     * @return
     */
    int updateAppUserAlipay(@Param("userId") Long userId, @Param("userRealName") String userRealName, @Param("alipayAccount") String alipayAccount, @Param("alipayPhoneNumber") String alipayPhoneNumber);

    /**
     * @param userId
     * @param balance
     * @return
     */
    int updateAppUserSubbalance(@Param("userId") Long userId, @Param("balance") BigDecimal balance);

    /**
     * @param userId
     * @param userRealName
     * @param alipayAccount
     * @return
     */
    int updateAppUserAlipaytwo(@Param("userId") Long userId, @Param("userRealName") String userRealName, @Param("alipayAccount") String alipayAccount, @Param("alipayPhoneNumber") String alipayPhoneNumber);


    int updateAppUserphone(@Param("phoneNumber") String phoneNumber, @Param("unionId") String unionId);

    /**
     * @param userId
     * @return
     */
    AppUser selectAppUserBybalance(Long userId);

    /**
     * @param meInviteCode
     * @return
     */
    int selectFansBySuperInviteCodeSum(String meInviteCode);

    /**
     * @param meInviteCode
     * @param sj
     * @return
     */
    int selectFansDaySuperInviteCodeSum(@Param("meInviteCode") String meInviteCode, @Param("sj") Long sj);

    /**
     * @param meInviteCode
     * @param sj
     * @return
     */
    int selectFansDaySuperInviteMeInviteCodeSum(@Param("meInviteCode") String meInviteCode, @Param("sj") Long sj);

    /**
     * @param meInviteCode
     * @return
     */
    int selectFansBySuperInviteMeInviteCodeSum(String meInviteCode);

    /**
     * @param userName
     * @return
     */
    List<AppUser> downloadUserInformation(String userName);

    /**
     * @param userId
     * @return
     */
    AppUser selectAppUserByUserId(long userId);

    /**
     * @param taobaoUserId
     * @return
     */
    Double selectTotalUserCommssionByTaobaoUserId(Long taobaoUserId);

    /**
     * @param userId
     * @param name
     * @param start
     * @param back
     * @return
     */
    List<AppUser> teamInviteUserList(@Param("userId") Long userId, @Param("name") String name, @Param("start") Integer start, @Param("back") Integer back);

    /**
     * @param userId
     * @param name
     * @param start
     * @param back
     * @return
     */
    List<AppUser> teamInviteLevelUserList(@Param("userId") Long userId, @Param("name") String name, @Param("start") Integer start, @Param("back") Integer back);

    /**
     * @param superInviteCode
     * @return
     */
    AppUser selectSuperUserInfoBySuperInviteCode(String superInviteCode);


    /**
     * @param relationId
     * @return
     */
    AppUser findUserInfoByRelationId(Long relationId);

    /**
     * @param relationId
     * @return
     */
    AppUser findUserInfoBySpecialId(Long relationId);

    /**
     * @param userId
     * @param commission
     * @return
     */
    int updateAppUseraddbalance(@Param("userId") Long userId, @Param("commission") BigDecimal commission);

    /**
     * @param appUserId
     * @return
     */
    AppUser findRelationIdANDMeInviteCode(Long appUserId);

    /**
     * @param meInviteCode
     * @return
     */
    List<AppUser> findLevalRelationIdANDMeInviteCode(String meInviteCode);

    /**
     * @param meInviteCode
     * @return
     */
    List<AppUser> findLeval2RelationIdANDMeInviteCode(String meInviteCode);

    /**
     * @param meInviteCode
     * @return
     */
    List<AppUser> selectFansByLevelInviteCode(String meInviteCode);

    /**
     * @return
     */
    List<AppUser> findUserIn(Integer companyId);

    /**
     * @return
     */
    List<AppUser> findUserNotIn(Integer companyId);

    /**
     * @param userId
     * @return
     */
    List<AppUser> findOnesFen(Long userId);

    /**
     * @param userId
     * @return
     */
    List<AppUser> findTwosFen(Long userId);

    /**
     * @param appUser
     * @return
     */
    List<AppUser> selectAppUserListByUnionId(AppUser appUser);

    /**
     * 修改APP用户授权首次登录
     *
     * @param appUser 修改APP用户授权首次登录
     * @return 结果
     */
    int updateAppLogin(AppUser appUser);


    /**
     * 根据用户id查询粉丝数量
     *
     * @param userId
     * @return
     */
    int selectCountFS(Long userId);

    int updateAlipayPhoneNumber(@Param("alipayPhoneNumber") String alipayPhoneNumber, @Param("userId") Long userId);

    /**
     * 签到提醒开关
     */
    int updateSignPushByUserId(@Param("userId") Long userId, @Param("signPush") String signPush);

    /**
     * 更新用户可提现
     *
     * @param hbMoney
     * @param userId
     * @return
     */
    int updateBalance(@Param("hbMoney") BigDecimal hbMoney, @Param("userId") Long userId);

    /**
     * 手机号登录开关
     *
     * @param tableId
     * @return
     */
    LoginSwitch selectLoginSwitch(int tableId);


    /**
     * @param userRealName
     * @param alipayAccount
     * @return
     */
    List<AppUser> selectUserByUserNameAndAlipayAccount(@Param("userRealName") String userRealName, @Param("alipayAccount") String alipayAccount);


    /**
     * 批量更新用户
     *
     * @param companyId
     * @return
     */
    int updateBatchByCompanyId(@Param("inviteCode") String inviteCode, @Param("minviteCode") String minviteCode, @Param("companyId") Integer companyId);

    /**
     * 总邀请花费
     *
     * @param companyId
     * @param flag
     * @return
     */
    Double totalInvitationCost(@Param("companyId") Integer companyId, @Param("flag") Integer flag);

    /**
     * 昨日邀请花费
     *
     * @return
     */
    int invitationExpenseYesterday();

    /**
     * 今日之前总人数（昨日总人数）
     *
     * @param companyId
     * @return
     */
    int totalNumberYesterday(@Param("companyId") Integer companyId, @Param("flag") Integer flag);

    /**
     * 总邀请人数
     *
     * @param companyId
     * @param flag
     * @return
     */
    int numberOfInvitations(@Param("flag") Integer flag, @Param("companyId") Integer companyId);

    Integer selectCountParticipants(@Param("type") Integer type);


    List<String> selectNoSignUsers();

    List<String> selectAllUsers();

    /**
     * 查询没有发送过指定类型的用户
     *
     * @param logType
     * @return
     */
    List<AppUser> queryAppUserSm(@Param("logType") Integer logType);

    List<AppUser> sendCopyLinkMessage();


    /**
     * 查询用户列表
     *
     * @return
     */
    List<AppUser> selectAppUserListNew(HashMap<String, Object> hashMap);

    /**
     * 总条数
     *
     * @param map
     * @return
     */
    Long selectAppUserListNewCount(HashMap<String, Object> map);

    List<Long> selectUserIdCreateUserMonye();

    List<AppUser> selectUserNotOrder();

    List<Long> updateUserNotOrderBlack();

    Long selectUserCount();

    Integer selectRegistUser(@Param("channelId") Long channelId, @Param("flag") Integer flag);

    List<ChannelUserAffiliationVo> selectChannelUserNotAffiliation();

    int updateAppUserCompanyByUserId(@Param("userId") Long userId, @Param("companyId") Integer companyId);

    int updateAppUserSqjdbalance(@Param("userId") Long userId, @Param("commission") BigDecimal commission);

    List<AppUser> selectAppUserByTaobaoId(String taobaoUserId);

	Integer sqjdRegistNum();

    Integer sqjdAllRegistNum();

    Integer zgsAllRegistNum(@Param("type")Integer type);

    Integer addPayOrder(@Param("type")Integer type);
}